package mdc;

import javax.servlet.*;
import java.io.IOException;

/**
 * @program: pangu
 * @description:
 * @author: fengjd
 * @create: 2022-06-23 08:57
 **/
public class LogFilter implements Filter {
    @Override
    public void init(FilterConfig filterConfig) throws ServletException {
    }

    @Override
    public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {
//        MdcUtil.add(UUID.randomUUID().toString());
        System.out.println("记录请求日志");
        try {
            chain.doFilter(request, response);
        } catch (IOException e) {
            e.printStackTrace();
        }
        System.out.println("记录响应日志");
    }

    @Override
    public void destroy() {
    }
}
